<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<%@ include file="/common-app/taglibs.jsp"%>
<%@ taglib uri="/WEB-INF/iristaglib.tld" prefix="iris"%>
<!DOCTYPE html>
<html>
<head>
<title>项目审核</title>
<%@ include file="/common/meta.jsp"%>

<script type="text/javascript" src="${res}/js/opinion/opinion.js"></script>
<script type="text/javascript" src="${res}/js/validate/irisvalidator.js"></script>
<script type="text/javascript" src="${res}/js/proposal/irisPrpPrepare.js"></script>
<script type="text/javascript">
var prcWin = new progressWin("${res}");//初始化遮罩层
messageTip.check_nopass="提示信息";
function processsFun(type){
	    
	    //获取申报书查看页面的附件清单
	    var passFiles = "";
	    var isExtsis = false;
	    
	    try{
		     passFiles =  document.getElementById("prpFrame").contentWindow.setAttachMessage("prpContent_upload");
		     //isExtsis =  document.getElementById("prpFrame").contentWindow.isExistAttach();//判断申报书是否有附件
	    }catch(ex){
	    	//拿不到符合的附件清单号
	    	//isExtsis=false;
	    }
	    
		$("#passFiles").attr("value",passFiles);
        
		var opn = $("#opinionContent").val();
		if(opn==null||opn==""){
			opn = $("#opinionContent").text();
		}
		if($.trim(opn).length==0){
			scmWarn("请输入审核意见!");
			return false;
		}
		if(opn.length>500){
			scmWarn("审核意见限500字内!");
			return false;
		}
		/*
		if(isExtsis){
		 if("${param.roleId}"=="8"){
			if(passFiles==""&&type=='return'){
				if(!window.confirm("确定没有一个附件符合条件吗？")){
				   return false;
			    }
			}
		 }
		}
		*/
		if(type=="return"){
			if(!window.confirm("确定退回该项目吗？")){
				   return false;
			}
		}
		
		if(type=="notpass"){
			if(!window.confirm("确定不同意申报吗？如果确定，该申请书将作废。")){
				   return false;
			}
		}
		var prpCode = encodeURIComponent("${prpCodes}");
		
		var options = {
				type:'post',
				data:{
					"prpCodes":prpCode,
					"type":"${param.type}",
					"status":"${param.status}",
					"category":"${userOpinion.category}",
					"opinion":opn,
					"fileCode":encodeURIComponent($("#file_code").val()),
					"fileName":$("#file_name").text(),
					"passFiles":passFiles
					
				},
				beforeSend : function() {
					$("input[type='button'][id!='back']").attr("disabled",true);
					$("#type").attr("value",type);
					//$("#passFiles").attr("value",passFiles);
					//prcWin.openWin();//打开遮罩层
					
				}, // 表单提交前的回调函数
				success : function(msg) {
						if(msg.indexOf(":")!=-1){
							var obj = eval("(" + msg + ")");
							if(obj.checkList!=null){
								var list = obj.checkList ;
								for ( var i = 0; i < list.length; i++) {
									irisValaddMsg(list[i]);
								}
								prcWin.closeWin();
								irisValShowMsg($("#wbox1"));
								$("input[type='button'][id!='back']").attr("disabled",false);
								return ;
							} 
						}
					if(msg.indexOf('操作成功')!=-1 || msg=='success')
						scmSuccess(msg);
					else{
						prcWin.closeWin();
						irisValaddMsg(msg);
						irisValShowMsg($("#wbox1"));
						$("input[type='button'][id!='back']").attr("disabled",false);
						return ;
					}
					prcWin.closeWin();
					//parent.$("#searchBt").click();
					//parent.irisGrid.getGridDom().jqGrid("refresh",0);//0是本页1是首页
					parent.currefresh=false;
					window.parent.opener.search();
					parent.reflushBu();
					window.setTimeout("window.close()", 2000);
					$("input[type='button'][id!='back']").attr("disabled",false);
				
				},// 表单成功提交后的回调函数
				error : function() {
					scmError("操作失败,请联系系统管理员");
					$("input[type='button'][id!='back']").attr("disabled",false);
					//prcWin.closeWin();
				},
				url: "${ctx}/tech-ctr/"+type
			};
		$.ajax(options);
	//$("#mainForm").ajaxSubmit(options);
	//	parent.irisGrid.getGridDom().jqGrid("refresh",0);//0是本页1是首页
}

$(document).ready(function(){
	fileInit("prpContent_upload",null,null,null);
$("#back").click(function(){
	//parent.irisGrid.getGridDom().jqGrid("refresh",0);//0是本页1是首页
	//parent.$("#searchBt").click();
	//parent.tb_remove();
	window.close();
});
refreshOpinins();

<c:if test="${not empty param.flagAudit }">
$('#approve').val("审议完成");
</c:if>
});



function openbackupapprovedialog(flag){
	if (flag) {
		var url="${ctx}/tech-ctr/openbackupapprovedialog?category=${userOpinion.category}&flag="+flag+"&showGrant=true&TB_iframe=true&height=390&width=720";
		var title="";
		tb_show(title,url,false);
	}
}

function viewComment(){
	
	var url="${ctx}/proposal/view/audit-comment-view?posCode="+encodeURIComponent("${param.posCode}")+"&flag=historyOpinion&TB_iframe=true&height=390&width=720";
    var title="历史审核意见";
    tb_show(title,url,false);
}





function setChangeValue(selObj){
	if (selObj.value > 0)
		$("#opinionContent").val($(selObj).find("option:selected").attr("title"));
	else 
		$("#opinionContent").val("");
}
//刷新意见下拉列表
function refreshOpinins(){
	$.ajax({
		async:true,
		type:'post',
		data:{
			"userOpinion.grantCode":"${grantCode}",
			"userOpinion.category":"${userOpinion.category}",
			"flag":"ajaxOpinions"
		},
		success : function(data) {
			$("#opininsSpan").html("");
				var opinins='<select onchange="setChangeValue(this)" style="width:150px; overflow:hidden">'+
								'<option value="-1">请选择</option>';
				for (var i in data) {
					   if(data[i].content.length > 20){
					       opinins+='<option title = "'+data[i].content+'" value="'+data[i].id+'">'+data[i].content.substr(0,20)+"......"+'</option>';
					   }else{
						   opinins+='<option title = "'+data[i].content+'" value="'+data[i].id+'">'+data[i].content+'</option>';
					   }
				}
					opinins+='</select>';
				$("#opininsSpan").html(opinins);
		
		},
		error : function() {
			scmError("操作失败,请联系系统管理员");
		},
		url: "${ctx}/tech-ctr/openbackupapprovedialog"
	});
}


</script>
</head>
<body>

    <center>

        <iframe id="prpFrame"  frameborder="0"   height="500px" width="1000px" src=""></iframe>

	</center>
     
    
	<!-- <form method="post" id="mainForm"> -->
		<input type="hidden" name="prpCodes" value="${prpCodes}" />
		<input type="hidden" id="type" name="type" value="${param.type}" />
		<input type="hidden" id="category" value="${userOpinion.category}"/>
		
		<input type="hidden" id="passFiles" name="passFiles" value="" />
		
		
		
		<center>
		<c:if test="${not empty param.flagAudit }">

		<table class="t_css" width="970px" align="center"  border="0" cellpadding="0" cellspacing="1"  id="prpContent_upload">
		<tr>
								<td align="right" width="43%">专题评议纪要附件：</td>
								<td align="left">
									<input type="file" name="filedata" />&nbsp;<input type="hidden" name="file_code" id="file_code" value="" />
								</td>
								<td></td>
							</tr>
							<tr id="uploadsuccess"  style="display:none" >
							    <td align="right" width="12%">您已经上传文件：</td>
								<td align="left">
									<a id="content_downLoadFile" class="link_x">
									<span name="file_name" id="file_name"></span></a>&nbsp;&nbsp;
									<a href="###" class="link_x" onclick="delContent('prpContent_upload')">删除</a>
							    </td>
							    <td></td>
							    
							</tr>
		</table>
		</c:if>
			选择常用审核意见：
			<span id="opininsSpan"></span>
			<div>
			    <button onclick="javascript:viewComment()" class="button_01">查看历史审核意见</button>
				<button onclick="saveUserOpinion('${ctx}', this, 'main-opinion')" class="button_01">添加至常用意见箱</button>
				<button onclick="openbackupapprovedialog('list4opinions')" class="button_01">编辑常用意见箱</button>
			</div>
			 <table class="t_css" width="970px"  border="0" cellpadding="0" cellspacing="1">
		        <tr class="li_1">
		          <td width="100%"><textarea name="opinionContent" id="opinionContent" style="width:100%" rows="8" maxlength="500" onfocus="InitInput.setMaxLength(this,500)"></textarea></td>
		        </tr>
	      	</table>
	      	<br/>
      	</center>
      	<br/>
      <div style="text-align: center;">


        &nbsp;<input type="button" class="button_01" value="审核通过" id="approve" processType="approve" onclick="processsFun('approve')"/>

 
  
    
      	 &nbsp;<input type="button" class="button_01" value="退回修改" id="return" processType="return" onclick="processsFun('return')"/>

    <%--  <security:authorize ifNotGranted="A_PROPOSAL_AD_SUBMIT">
      	&nbsp;<input type="button" class="button_01" value="不同意申报" id="veto" processType="notpass" onclick="processsFun('notpass')"/>
     </security:authorize> --%>
      

     
        &nbsp;<input type="button" class="button_01" value="关闭" id="back"/>
		</div>
	<!-- </form> -->
	
		<script type="text/javascript">
	function loadPrpView(){
		//alert();
		  //document.getElementById("prpFrame").src = "${ctx}/proposal/view-prp?posCodeStr="+encodeURIComponent("${param.posCode}")+"&grantCodeStr=<iris:des3 code="${param.grantCode}|${curDate}" encryptKey="111111222222333333444444" />&subGrantCodeStr=<iris:des3 code="${param.subGrantCode}|${curDate}" encryptKey="111111222222333333444444" />";
		document.getElementById("prpFrame").src = "${ctx}/proposal/view-prp?posCodeStr="+encodeURIComponent("${param.posCode}")+"&grantCodeStr="+encodeURIComponent("${param.grantCode}")+"&subGrantCodeStr="+encodeURIComponent("${param.subGrantCode}");
	}
	
	
	

	loadPrpView();
	</script>
	

	
</body>
</html>